﻿using DataAccess.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Class_Entity.ObjectTwo;
namespace BussinessObject.ObjectTwo
{
   public class B_GetAccount
    {
        D_GetAccount ex = new D_GetAccount();
        Account fx = new Account();
        DataTable tb = new DataTable();
        public Account getAccount(String User)
        {
            tb = ex.GetAccount(User);
            foreach (DataRow ds in tb.Rows)
            {
                fx.LAST_NAME = tb.Rows[0]["LAST_NAME"].ToString();
                fx.FIRST_NAME = tb.Rows[0]["FIRST_NAME"].ToString();
                fx.EMAIL = tb.Rows[0]["EMAIL"].ToString();
                fx.ADDRESS = tb.Rows[0]["ADDRESS"].ToString();
                fx.PHONE_NUMBER = tb.Rows[0]["PHONE_NUMBER"].ToString();
                fx.PICTURE = tb.Rows[0]["PICTURE"].ToString();
                fx.BIRTH_DATE = tb.Rows[0]["BIRTH_DATE"].ToString();                
            }
            return fx;
        }
        public bool UpdateAccount(Account fx)
        {
            return ex.UpdateAccount(fx);
        }
        public DataTable getvalAccount(String user)
        {
            return ex.GetAccount(user);
        }
        public Account getvalAccountID(int user)
        {
            tb = ex.GetAccountID(user);
            foreach (DataRow ds in tb.Rows)
            {
                fx.USER_NAME = tb.Rows[0]["USER_NAME"].ToString();
                fx.LAST_NAME = tb.Rows[0]["LAST_NAME"].ToString();
                fx.FIRST_NAME = tb.Rows[0]["FIRST_NAME"].ToString();
                fx.EMAIL = tb.Rows[0]["EMAIL"].ToString();
                fx.ADDRESS = tb.Rows[0]["ADDRESS"].ToString();
                fx.PHONE_NUMBER = tb.Rows[0]["PHONE_NUMBER"].ToString();
                fx.PICTURE = tb.Rows[0]["PICTURE"].ToString();
                fx.BIRTH_DATE = tb.Rows[0]["BIRTH_DATE"].ToString();               
            }
            return fx;
        }
        public bool InsertNewAccount(Account fx)
        {
            return ex.InsertAccount(fx);
        }
        public DataTable getPin(String pin)
        {
            return ex.CheckPin(pin);
        }
        public DataTable SearchAccount(String values)
        {
            return ex.SearchAccount(values);
        }
        public bool ChangePass(int val, String pass)
        {
            return ex.ChangePass(val, pass);
        }
    }
}
